﻿@using System.Text.RegularExpressions
@{
    Layout = "~/Modules/Common/Views/Shared/_Layout.cshtml";
    Easy.Web.CMS.Layout.LayoutEntity layOut = ViewData[Easy.Web.CMS.Layout.LayoutEntity.LayoutKey] as Easy.Web.CMS.Layout.LayoutEntity;
    if (layOut == null)
    {
        return;
    }
}
@for (int i = 0; i < layOut.Html.Count; i++)
{
    var item = layOut.Html[i];
    if (item.Html == Easy.Web.CMS.Zone.ZoneEntity.ZoneTag)
    {
        i++;
        var zoneId = layOut.Html[i].Html;
        if (layOut.ZoneWidgets.ContainsKey(zoneId))
        {
            foreach (var widgetPart in layOut.ZoneWidgets[zoneId].OrderBy(m => m.Widget.Position).ThenBy(m => m.Widget.WidgetName))
            {
                <div @widgetPart.Widget.StyleClassResult()>
                    @{
                Html.RenderPartial(widgetPart.Widget.PartialView, widgetPart.ViewModel);
                    }
                </div>
            }
        }
        i++;
    }
    else
    {
        @Html.Raw(item.Html)
    }
}

